const App = getApp();
Component({
    data: {
        isShow: false,
        // currentTab: 0,    // 默认首页为选中页面
        selected: 0,
        userType: '1',
        userId: '',
        color: "#9f9f9f",
        isClueShow: null,
        selectedColor: "#ff5f60",
        "list": [
            {
                "pagePath": "/brand/index/index",
                "text": "品牌首页",
                // "iconPath": "http://img.qian.gzzsu.com/shop/qiankanghui/home-img/%E5%93%81%E7%89%8C.png",
                // "selectedIconPath": "http://img.qian.gzzsu.com/shop/qiankanghui/home-img/%E5%93%81%E7%89%8C1.png"
                "iconPath": "/brand/assets/images/品牌.png",
                "selectedIconPath": "/brand/assets/images/品牌1.png"
            },
            {
                "pagePath": "/brand/brand/classify",
                "text": "品牌选品",
                // "iconPath": "http://img.qian.gzzsu.com/shop/qiankanghui/home-img/%E9%80%89%E5%93%81%E5%BA%93.png",
                // "selectedIconPath": "http://img.qian.gzzsu.com/shop/qiankanghui/home-img/%E9%80%89%E5%93%81%E5%BA%931.png",
                "iconPath": "/brand/assets/images/选品库.png",
                "selectedIconPath": "/brand/assets/images/选品库1.png"
            },
            {
                "pagePath": "/brand/health/health",
                "text": "品牌健康",
                // "iconPath": "http://img.qian.gzzsu.com/shop/qiankanghui/home-img/%E5%81%A5%E5%BA%B7.png",
                // "selectedIconPath": "http://img.qian.gzzsu.com/shop/qiankanghui/home-img/%E5%81%A5%E5%BA%B71.png",
                "iconPath": "/brand/assets/images/健康.png",
                "selectedIconPath": "/brand/assets/images/健康1.png"
            }
        ]
    },
    /**
     * 组件的属性列表
     */
    properties: {
        currentindex: {
            type: Number,
            value: 0
        },

    },
    attached() {
        // 获取全局变量进行设置展示
        this.setData({
            selected: App.globalData.tabindex
        })
    },
    methods: {
        // 路由跳转
        switchTab(e) {
            const data = e.currentTarget.dataset
            let index = data.index
            // 重复点击直接跳出 不滑动页面
            if (index == this.data.currentindex) return
            // 将索引修改到全局变量
            App.globalData.tabindex = index
            this.setData({
                currentindex: index
            })

            // 调用父组件方法
            this.triggerEvent('handleChange', index)
        },
    }
})